import instance from "./require";
import type { shopTS, typeTS } from "../store/crmsTS";

//获取商品列表数据
export let http_shoplist = (): Promise<Array<shopTS>> => {
    return instance.get('/shoplist1')
}

//获取分类列表数据
export let http_typelist = (): Promise<Array<typeTS>> => {
    return instance.get('/typelist1')
}

//商品列表添加的方法
export let http_addshoplist = (obj: shopTS): Promise<shopTS> => {
    return instance.post('/shoplist1', obj)
}
//商品列表编辑的方法
export let http_editshoplist = (obj: shopTS): Promise<shopTS> => {
    return instance.patch(`/shoplist1/${obj.id}`, obj)
}
//商品列表删除的方法
export let http_delshoplist = (id: number) => {
    return instance.delete(`/shoplist1/${id}`)
}
//商品列表搜索的方法
export let http_searchshoplist = (title: string):Promise<Array<shopTS>> => {
    return instance.get('/shoplist1', { params: { 'title_like': title } })
}


//分类列表添加的方法 
export let http_addtypelist=(obj:typeTS):Promise<typeTS>=>{
    return instance.post('/typelist1',obj)
}
//分类列表删除的方法
export let http_deltypelist=(id:number)=>{
    return instance.delete(`/typelist1/${id}`)
}